package com.smartcruise.util.image;

import android.content.Context;

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.cache.DiskCache;
import com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper;
import com.bumptech.glide.module.AppGlideModule;
import com.smartcruise.util.FileUtils;

import java.io.File;

/**
 * Created by FengChaoQun
 * on 2016/9/14
 * <p>
 * modified by FengChaoQun on 2017/11/14 0014 18:33
 * description:升级Glide到4.3.1
 */
@GlideModule
public class MyGlideModule extends AppGlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        builder.setDiskCache(new DiskCache.Factory() {
            @Override
            public DiskCache build() {
                File file = new File(FileUtils.getGlideCache());
                if (!file.exists()) {
                    file.mkdirs();
                }
                return DiskLruCacheWrapper.get(file, 300 * FileUtils.MB);
            }
        });
    }
}
